Distribution values predictors

Frequency outcome variable

Distribution of response types across RelX and RelY

Model effect relative position of referents

con_mat <- cbind(c(2, -1, -1), c(0, 1, -1))
contrasts(data$condition) <- con_mat

model1 <- glmer(response1 ~ relY + relX + relY:relX + (1 + relY|id), data = data, family = binomial("logit"),  glmerControl(optimizer="bobyqa", optCtrl = list(maxfun = 100000)))

summary(model1)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: response1 ~ relY + relX + relY:relX + (1 + relY | id)
##    Data: data
## Control: 
## glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##  36040.5  36099.0 -18013.3  36026.5    31387 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -9.8915 -0.7995  0.1095  0.7984 15.3916 
## 
## Random effects:
##  Groups Name        Variance Std.Dev. Corr 
##  id     (Intercept) 0.003348 0.05786       
##         relY        5.539862 2.35369  -0.54
## Number of obs: 31394, groups:  id, 80
## 
## Fixed effects:
##             Estimate Std. Error z value Pr(>|z|)    
## (Intercept)  0.01410    0.01454   0.970    0.332    
## relY        -2.58403    0.26641  -9.699   <2e-16 ***
## relX         0.31590    0.01886  16.750   <2e-16 ***
## relY:relX    0.04028    0.05925   0.680    0.497    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr) relY   relX  
## relY      -0.237              
## relX      -0.014 -0.010       
## relY:relX -0.050 -0.003  0.008

Effect of social context: Model comparison

model2 <- glmer(response1 ~ relY + relX + relY:relX + relY: condition + relX:condition + relY:relX:condition + (1+ relY|id), data = data, family = binomial("logit"), glmerControl(optimizer="bobyqa", optCtrl = list(maxfun = 100000)))

anova(model1, model2)
## Data: data
## Models:
## model1: response1 ~ relY + relX + relY:relX + (1 + relY | id)
## model2: response1 ~ relY + relX + relY:relX + relY:condition + relX:condition + 
## model2:     relY:relX:condition + (1 + relY | id)
##        Df   AIC   BIC logLik deviance  Chisq Chi Df Pr(>Chisq)  
## model1  7 36041 36099 -18013    36027                           
## model2 13 36036 36144 -18005    36010 16.794      6    0.01007 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Effect of social context: Model summary

## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: binomial  ( logit )
## Formula: 
## response1 ~ relY + relX + relY:relX + relY:condition + relX:condition +  
##     relY:relX:condition + (1 + relY | id)
##    Data: data
## Control: 
## glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 1e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##  36035.7  36144.3 -18004.9  36009.7    31381 
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -10.0996  -0.7994   0.1078   0.7968  16.0036 
## 
## Random effects:
##  Groups Name        Variance Std.Dev. Corr 
##  id     (Intercept) 0.003288 0.05734       
##         relY        5.547638 2.35534  -0.54
## Number of obs: 31394, groups:  id, 80
## 
## Fixed effects:
##                        Estimate Std. Error z value Pr(>|z|)    
## (Intercept)           0.0142272  0.0145196   0.980   0.3272    
## relY                 -2.5861324  0.2666052  -9.700   <2e-16 ***
## relX                  0.3164362  0.0188695  16.770   <2e-16 ***
## relY:relX             0.0385945  0.0592855   0.651   0.5151    
## relY:condition1      -0.0686767  0.0272873  -2.517   0.0118 *  
## relY:condition2      -0.1145488  0.0467048  -2.453   0.0142 *  
## relX:condition1      -0.0010535  0.0133574  -0.079   0.9371    
## relX:condition2       0.0499000  0.0230121   2.168   0.0301 *  
## relY:relX:condition1 -0.0006996  0.0418850  -0.017   0.9867    
## relY:relX:condition2 -0.0227176  0.0718073  -0.316   0.7517    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) relY   relX   rlY:rX rlY:c1 rlY:c2 rlX:c1 rlX:c2 rY:X:1
## relY        -0.235                                                        
## relX        -0.014 -0.010                                                 
## relY:relX   -0.050 -0.003  0.007                                          
## relY:cndtn1  0.000  0.003  0.000  0.003                                   
## relY:cndtn2 -0.003  0.003 -0.011  0.003 -0.010                            
## relX:cndtn1  0.000  0.000  0.008  0.000 -0.051  0.007                     
## relX:cndtn2  0.000 -0.002  0.013 -0.006  0.007 -0.052 -0.009              
## rlY:rlX:cn1  0.001  0.000  0.000  0.014 -0.023 -0.002  0.007  0.005       
## rlY:rlX:cn2 -0.009  0.001 -0.007  0.014 -0.002 -0.027  0.005  0.007 -0.010

Diagnostic plots

All coefficients

Plot effects

predProbs = predict(model2, type="response")

relX <- ggplot(data, aes(relX, predProbs)) +
stat_smooth(method="glm", formula=y~splines::ns(x,3),
              alpha=0.2, size=0.5) + xlab("Distance between targets on x axis")+ ylab("Predicted probability of proximal demonstrative") + ggtitle("Effect RelX")

int_x <- ggplot(data, aes(relX, predProbs, color=condition)) +
stat_smooth(method="glm", formula=y~splines::ns(x,3),
              alpha=0.2, size=0.5, aes(fill=condition), se = F) + xlab("Distance between targets on x axis")+ ylab("Predicted probability of proximal demonstrative") + ggtitle("Interaction RelX by Condition")

relY <- ggplot(data, aes(relY, predProbs)) +
stat_smooth(method="glm", formula=y~splines::ns(x,3),alpha=0.2, size=0.5) + xlab("Distance between targets on y axis")+ ylab("Predicted probability of proximal demonstrative") + ggtitle("Effect RelY")

int_y <- ggplot(data, aes(relY, predProbs, color=condition)) +
stat_smooth(method="glm", formula=y~splines::ns(x,3),
              alpha=0.2, size=0.5, aes(fill=condition), se = F) + xlab("Distance between targets on y axis")+ ylab("Predicted probability of proximal demonstrative") + ggtitle("Interaction RelY by Condition")

relX

int_x

relY

int_y

Heatmaps (RelX / RelY)